package com.dfbz.demo01_卖票案例;

/**
 * @author lscl
 * @version 1.0
 * @intro:
 */
public class Demo08_线程的休眠 {
    public static void main(String[] args) {

        new Thread("线程A"){
            @Override
            public void run() {
                for (int i = 0; i < 1000; i++) {

                    if(i == 5){
                        try {
                            // 如果线程休眠了,会把CPU的执行权限让出来
                            Thread.sleep(100);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                    System.out.println(Thread.currentThread().getName());
                }
            }
        }.start();



        new Thread("线程B"){
            @Override
            public void run() {
                for (int i = 0; i < 1000; i++) {
                    System.out.println(Thread.currentThread().getName());
                }
            }
        }.start();


    }
}
